package org.example.ExperimentTwo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringChangetoDate {
    public static void main(String[] args) {
        String dateString = "1981-09-19 09:07:27.727";
//        模式
        String pattern = "yyyy-MM-dd HH:mm:ss.SSS";
//创建一个SimpleDateFormat对象
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        Date date = null;

        try {
            date = sdf.parse(dateString);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        System.out.println("转换后的Date型数据：" + date);
    }
}
